
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="language" content="en" />
        <?php
        $id = $_GET['id'];
        $shopcode = 'shop' . $id;
        if (isset(Yii::app()->request->cookies[$shopcode]->value)) {
            $shop = Yii::app()->request->cookies[$shopcode]->value;
        } else {
            $shoplist = Shop::model()->findAll(' `flag`=1 and `shopCode`="' . $id . '"');

            if (!empty($shoplist)) {
                foreach ($shoplist as $c) {
                    $idshop = $c->id;
                    $shopName = $c->shopName;
                    $shopCode = $c->shopCode;
                    $shopshop = array($idshop, $shopName, $shopCode, $c->logo, $c->url_logo, $c->footer, $c->address, $c->phone, $c->metakeyword, $c->metadisception, $c->yotube,$c->facebook,$c->google,$c->twitter,$c->uid);
                }

               
                if (!empty($shopshop)) {
                   
                    $json = json_encode($shopshop, true);

                    $cookie = new CHttpCookie($shopcode, $json);

                    $cookie->expire = time() + 60 * 60 * 1;
                    Yii::app()->request->cookies[$shopcode] = $cookie;
                } else {
                    $this->redirect('http://salesmartlink.com');
                }
            } else {
                $this->redirect('http://salesmartlink.com');
            }
        }
        $shoparry = Yii::app()->request->cookies[$shopcode]->value;
        //$shopary = stripslashes($shoparry); dong nay bo dau tieng viet
        $savedCardArray = json_decode($shoparry, true);
        ?>

        <meta name="keywords" content="<?php echo $savedCardArray[8]; ?>" />
        <meta name="description" content="<?php echo $savedCardArray[9]; ?> " />
        <title><?php echo $savedCardArray[1]; ?></title>
        <link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/icon/favicon.ico" type="image/x-icon" />
        <!-- blueprint CSS framework -->
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/shop/home/css.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/shop/home/cssmenu.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/shop/home/buttons.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/pager.css" />
        <link href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/menuV2.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/jsImgSlider/themes/6/js-image-slider.css" />
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jsImgSlider/themes/6/mcVideoPlugin_1.js" type="text/javascript"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jsImgSlider/themes/6/js-image-slider_1.js" type="text/javascript"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/home/menuV2.js" type="text/javascript"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/home/jquery.countdown.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/shop/skins/tango/skin.css" />

        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/productslider/jquery.jcarousel.min.js"></script>


        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.msgBox/Scripts/jquery.msgBox.js"></script>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.msgBox/Styles/msgBoxLight.css" />
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/ui/jquery-ui.js"></script>

        <script type="text/javascript">

            function resize()
            {
                var $winwidth = $(window).width();

                if ($winwidth > 1349) {
                    var freeSpace = $winwidth - 381;
                    $("#nd").width($winwidth);
                    $("#head").width($winwidth);
                    $("#col").width(freeSpace);
                } else
                {
                    var freeSpace = 968;
                    $("#nd").width(1349);
                    $("#head").width(1349);
                    $("#col").width(freeSpace);
                }
            }



            $(document).ready(function() {
                $('a.login-window').click(function() {

                    // Getting the variable's value from a link 
                    var loginBox = $(this).attr('href');

                    //Fade in the Popup and add close button
                    $(loginBox).fadeIn(300);

                    //Set the center alignment padding + border
                    var popMargTop = ($(loginBox).height() + 24) / 2;
                    var popMargLeft = ($(loginBox).width() + 24) / 2;

                    $(loginBox).css({
                        'margin-top': -popMargTop,
                        'margin-left': -popMargLeft
                    });

                    // Add the mask to body
                    $('body').append('<div id="mask"></div>');
                    $('#mask').fadeIn(300);

                    return false;
                });

                // When clicking on the button close or the mask layer the popup closed
                $('a.close, #mask').live('click', function() {
                    $('#mask , .login-popup').fadeOut(300, function() {
                        $('#mask').remove();
                    });
                    return false;
                });
            });

        </script>

        <script type="text/javascript">
            // snowStorm.snowColor = '#99ccff'; // màu của tuyết - ở đây là màu xanh xám
            // snowStorm.flakesMaxActive = 96; // số lượng tuyết rơi cùng 1 lúc
            // snowStorm.useTwinkleEffect = true; // cho tuyết nhấp nháy

            //Configure below to change URL path to the snow image
            var snowsrc = "snow.gif"
            // Configure below to change number of snow to render
            var no = 10;
            // Configure whether snow should disappear after x seconds (0=never):
            var hidesnowtime = 0;
            // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
            var snowdistance = "pageheight";


            var ie4up = (document.all) ? 1 : 0;
            var ns6up = (document.getElementById && !document.all) ? 1 : 0;

            function iecompattest() {
                return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
            }

            var dx, xp, yp;    // coordinate and position variables
            var am, stx, sty;  // amplitude and step variables
            var i, doc_width = 800, doc_height = 600;

            if (ns6up) {
                doc_width = self.innerWidth;
                doc_height = self.innerHeight;
            } else if (ie4up) {
                doc_width = iecompattest().clientWidth;
                doc_height = iecompattest().clientHeight;
            }

            dx = new Array();
            xp = new Array();
            yp = new Array();
            am = new Array();
            stx = new Array();
            sty = new Array();
            snowsrc = (snowsrc.indexOf("http://salesmartlink.com/") != -1) ? "snow3.gif" : snowsrc
            for (i = 0; i < no; ++i) {
                dx[i] = 0;                        // set coordinate variables
                xp[i] = Math.random() * (doc_width - 50);  // set position variables
                yp[i] = Math.random() * doc_height;
                am[i] = Math.random() * 20;         // set amplitude variables
                stx[i] = 0.02 + Math.random() / 10; // set step variables
                sty[i] = 0.7 + Math.random();     // set step variables
                if (ie4up || ns6up) {
                    if (i == 0) {
                        document.write("<div id=\"dot" + i + "\" style=\"POSITION: absolute; Z-INDEX: " + i + "; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='http://salesmartlink.com/snow3.gif' border=\"0\"><\/a><\/div>");
                    } else {
                        document.write("<div id=\"dot" + i + "\" style=\"POSITION: absolute; Z-INDEX: " + i + "; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='http://salesmartlink.com/snow.gif' border=\"0\"><\/div>");
                    }
                }
            }

            function snowIE_NS6() {  // IE and NS6 main animation function
                doc_width = ns6up ? window.innerWidth - 10 : iecompattest().clientWidth - 10;
                doc_height = (window.innerHeight && snowdistance == "windowheight") ? window.innerHeight : (ie4up && snowdistance == "windowheight") ? iecompattest().clientHeight : (ie4up && !window.opera && snowdistance == "pageheight") ? iecompattest().scrollHeight : iecompattest().offsetHeight;
                for (i = 0; i < no; ++i) {  // iterate for every dot
                    yp[i] += sty[i];
                    if (yp[i] > doc_height - 50) {
                        xp[i] = Math.random() * (doc_width - am[i] - 30);
                        yp[i] = 0;
                        stx[i] = 0.02 + Math.random() / 10;
                        sty[i] = 0.7 + Math.random();
                    }
                    dx[i] += stx[i];
                    document.getElementById("dot" + i).style.top = yp[i] + "px";
                    document.getElementById("dot" + i).style.left = xp[i] + am[i] * Math.sin(dx[i]) + "px";
                }
                snowtimer = setTimeout("snowIE_NS6()", 10);
            }

            function hidesnow() {
                if (window.snowtimer)
                    clearTimeout(snowtimer)
                for (i = 0; i < no; i++)
                    document.getElementById("dot" + i).style.visibility = "hidden"
            }


            if (ie4up || ns6up) {
                snowIE_NS6();
                if (hidesnowtime > 0)
                    setTimeout("hidesnow()", hidesnowtime * 1000)
            }

        </script>

    </head>
    <body onload="resize()">

        <?php
        $baner = ShopPanel::model()->findAll(
                array(
                    'condition' => ' `flag`=1 and `type`=0 and shopid='.$savedCardArray[0].' order by vitri ASC',
                    'limit' => 30,
                )
        );
        if (!empty($baner)) {
            $lan = 0;
            $right = '';
            $flag = 0;
            $dem = 0;
            $dem1 = 0;
            $left = '';
            foreach ($baner as $b) {

                $h = 0;

                $lan = $lan + 1;

                if ($lan < 2) {
                    if ($b->kieu == 0) {
                        $h = 396;
                    } elseif ($b->kieu == 1) {
                        $h = 792;
                        $flag = 1;
                    }
                    $left = $left . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                } elseif ($lan < 3) {
                    if ($flag < 1) {
                        $left = $left . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="396"  border="0"></a>';
                    } else {
                        $flag = 2;
                        if ($b->kieu == 0) {
                            $dem = $dem + 1;
                            $h = 264;
                            if ($dem < 2) {
                                $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                            } elseif ($dem < 3) {
                                $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                            } elseif ($dem > 2) {
                                $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                                $dem = 0;
                            }
                        } elseif ($b->kieu == 2) {

                            $h = 264 + 266;
                            if ($dem == 1) {
                                $dem = 0;
                                $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                            } else {
                                $dem = 3;
                                $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                            }
                        } elseif ($b->kieu == 3) {
                            $h = 792;
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                        }
                    }
                } else {
                    $flag = 2;
                    if ($b->kieu == 0) {
                        $dem = $dem + 1;
                        $h = 264;
                        if ($dem < 2) {
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        } elseif ($dem < 3) {
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        } elseif ($dem > 2) {
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                            $dem = 0;
                        }
                    } elseif ($b->kieu == 2) {

                        $h = 264 + 266;
                        if ($dem == 1) {
                            $dem = 0;
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                        } else {
                            $dem = 3;
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        }
                    } elseif ($b->kieu == 3) {
                        $h = 792;
                        $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/uploadshop/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                    }
                }
            }
        }
        ?>

        <?php
        /*
          $a = Yii::app()->controller->action->id;
          echo '<br/> action '.$a;
          $b = Yii::app()->controller->id;
          echo '<br/> ctroler '.$b;
          echo '<br/>';
         */


        $this->renderPartial('//shopping/layouts/header');
        ?>


        <div id="nd" style="padding-top: 64px;" >


            <div class="Colum1">
                <?php 
                if(!empty($left)){
                echo $left;}?>
            </div>
            <div id="col" style="float: left;border: 1px slategray">
                <div class="noidungfix" id="content0" style="height: 379px;">
                    <div>
                        <div class="colleft">
                            <?php
                            $this->renderPartial('//shopping/layouts/nabar_home');
                            ?>
                            <div style="clear: both"></div>
                        </div>

                        <div class="colright" style="margin: 0px">

                            <?php
                            $this->renderPartial('//shopping/slider');
                            ?>

                            <div style="clear: both"></div>
                        </div>

                    </div>

                    <div  style="clear: both"></div>

                </div>
            </div>
            <div class="Colum3">
                <?php
                if(!empty($flag)){
                if ($flag > 1) {
                    ?>
                    <ul id="mycarousel1" class="jcarousel-skin-chacha">
                        <?php echo $right; ?>

                    </ul>
                    <?php
                }}
                ?>
            </div>
            <div class="clear"></div>
            <div id="content1" style="margin-top: -410px;">
                <?php echo $content; ?>

                 <div class="clear"></div>
            </div>


            <div style="margin-top: 20px; height: 20px"></div>

            <?php
            $this->renderPartial('//shopping/layouts/footer');
            ?>
        </div>
        <div class="clear"></div>
    </body>
</html>
